<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Twilio_demo extends MY_Controller {

	function __construct()
	{
		parent::__construct();
		// Load the library, call by the name of the
		// helper that you put the above function in to
		$this->load->helper('my-twilio-helper');  // references library/my-twilio-helper.php

		// Request the service object
		$this->twilio = get_twilio_service();
	}

	function index()
	{
		

		// make a call
		 try {
			$item = $this->twilio->account->calls->create(
				'+15005550006', // from this number
				'+32472181053',
				'http://demo.twilio.com/docs/voice.xml'
			);
			echo 'Started call: ' . $item->sid;
		 } 
		catch (Exception $e) {
        echo 'Error: ' . $e->getMessage();
    }
		
		
	}
	
	function call()
	{
		/**
		 * Make sure the classes we need are available
		 */
	

		$response = new Services_Twilio_Twiml();
		$response->say('Hello, you will now be connected with the caller');
		echo $response;
	}
	
	function sms ()
	{
		// make a call
		 try {
			$item = $this->twilio->account->messages->sendMessage(
			'+15005550006',	
			"+3278481459", // from this number
			"This is a test"
			);
			echo 'Started call: ' . $item->sid;
		 } 
		catch (Exception $e) {
        echo 'Error: ' . $e->getMessage();
    }
		
		/*$item = $this->twilio->account->messages->sendMessage(
		"+3278481459",
		'+15005550006',
		
		);*/
		 
	}

}

/* End of file twilio_demo.php */